var height = document.body.clientHeight
 $(".matchList").css("height",height-110);
var fn=0;
var start=3;
$(".type1").click(function(){
	start=3;
	fn=0;
	$(this).css("color","#F9C486");
	$(".type3").css("color","white");
	$(".type2").css("color","white");
	type(start)
})
$(".type2").click(function(){
	start=1;
	fn=0;
	$(this).css("color","#F9C486");
	$(".type1").css("color","white");
	$(".type3").css("color","white");
	type(start)
})
$(".type3").click(function(){
	start=2;
	fn=0;
	$(this).css("color","#F9C486");
	$(".type1").css("color","white");
	$(".type2").css("color","white");
	type(start)
})

function type(start){
	$.ajax({
		url:'../matchController/myMatch',
		data:{
			"start":start,
			"fn":0
		},
		success:function(data){
			console.log(data)
			if(data==null || data=="" ||data.length==0){
				 $(".matchList").html("<div><img src='../image/none.jpg' style='width: 300px;height:300px;margin-left: 225px;margin-top:100px;'></div>");
			}else{
				$(".matchList").html("");
				fn=fn+20;
				$.each(data,function(idex,item){
					var startDate = new Date(item.start_time).format("hh:mm");
					var remark='';
					if(item.remark==null || item.remark=="" || item.remark=="undefined"){
						remark="无";
					}else{
						remark=item.remark
					}
					$(".matchList").append("<div class='box'><div class='gamePicBox'><img class='gamePic' src='"+item.matchListpic+"'></div><div class='gameContentBox'><div class='gameTitle'>"+item.name+"</div><div class='gameRank'><div class='area'>段位："+item.lowest_rank+"-"+item.highest_rank+"</div><div class='area'>"+item.region+"</div></div><div class='gameReward'>奖励："+remark+"</div></div><div class='gameSignUp'><div class='beginTime'>"+startDate+"开赛</div><a href='../html/matchContent.html?id="+item.id+"'><div class='look'>查 看</div></a></div></div>");
				
				})
			}
			
		},
		error:function(){
			
		}
	})
}
$(function(){
	var start=3;
	type(start)
});
const scrollDom = document.getElementById('matchList');

scrollDom.onscroll = () => {
	if (scrollDom.clientHeight + parseInt(scrollDom.scrollTop) === scrollDom.scrollHeight) {
		$.ajax({
			url:'../matchController/myMatch',
			data:{
				"start":start,
				"fn":fn
			},
			success:function(data){
				console.log(data)
				fn=fn+20;
				$.each(data,function(idex,item){
					var startDate = new Date(item.start_time).format("hh:mm");
					var remark='';
					if(item.remark==null || item.remark=="" || item.remark=="undefined"){
						remark="无";
					}else{
						remark=item.remark
					}
					$(".matchList").append("<div class='box'><div class='gamePicBox'><img class='gamePic' src='"+item.matchListpic+"'></div><div class='gameContentBox'><div class='gameTitle'>"+item.name+"</div><div class='gameRank'><div class='area'>段位："+item.lowest_rank+"-"+item.highest_rank+"</div><div class='area'>"+item.region+"</div></div><div class='gameReward'>奖励："+remark+"</div></div><div class='gameSignUp'><div class='beginTime'>"+startDate+"开赛</div><a href='../html/matchContent.html?id="+item.id+"'><div class='look'>查 看</div></a></div></div>");
				
				})
			}
		})
	  }
}